
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Java常用类 · My Study Note</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="yanglonglong">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-toggle-chapters/toggle.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-flexible-alerts/style.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="jvm.html" />
    
    
    <link rel="prev" href="Java集合.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="https://www.yangllong.top/" target="_blank" class="custom-link">My Blog</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../Linux相关/">
            
                <a href="../Linux相关/">
            
                    
                    Linux相关
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../Linux相关/make工具的使用.html">
            
                <a href="../Linux相关/make工具的使用.html">
            
                    
                    Make工具的使用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../springboot/">
            
                <a href="../springboot/">
            
                    
                    Springboot
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../springboot/springboot一些遇到的问题.html">
            
                <a href="../springboot/springboot一些遇到的问题.html">
            
                    
                    Springboot一些遇到的问题
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../vue/">
            
                <a href="../vue/">
            
                    
                    Vue
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../vue/vue+ssm跨域问题.html">
            
                <a href="../vue/vue+ssm跨域问题.html">
            
                    
                    Vue+Ssm跨域问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../vue/vue-cli3.html">
            
                <a href="../vue/vue-cli3.html">
            
                    
                    Vue Cli3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../vue/安装vue.html">
            
                <a href="../vue/安装vue.html">
            
                    
                    安装Vue
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../其他/">
            
                <a href="../其他/">
            
                    
                    其他
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../其他/分布式系统.html">
            
                <a href="../其他/分布式系统.html">
            
                    
                    分布式系统
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../其他/图解http.html">
            
                <a href="../其他/图解http.html">
            
                    
                    图解Http
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../其他/消息队列.html">
            
                <a href="../其他/消息队列.html">
            
                    
                    消息队列
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../其他/爬虫.html">
            
                <a href="../其他/爬虫.html">
            
                    
                    爬虫
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../刷题/">
            
                <a href="../刷题/">
            
                    
                    刷题
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../刷题/NOJ.html">
            
                <a href="../刷题/NOJ.html">
            
                    
                    NOJ
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../刷题/leetcode/">
            
                <a href="../刷题/leetcode/">
            
                    
                    Leetcode
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../刷题/leetcode/107简单题.html">
            
                <a href="../刷题/leetcode/107简单题.html">
            
                    
                    107简单题
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.3.1" data-path="../刷题/leetcode/2两数相加.html">
            
                <a href="../刷题/leetcode/2两数相加.html">
            
                    
                    2两数相加
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3.2" data-path="../刷题/leetcode/3无重复子串的最大长度.html">
            
                <a href="../刷题/leetcode/3无重复子串的最大长度.html">
            
                    
                    3无重复子串的最大长度
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../刷题/扇贝杯csdn.html">
            
                <a href="../刷题/扇贝杯csdn.html">
            
                    
                    扇贝杯Csdn
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../刷题/排序算法.html">
            
                <a href="../刷题/排序算法.html">
            
                    
                    排序算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="../刷题/蓝桥杯.html">
            
                <a href="../刷题/蓝桥杯.html">
            
                    
                    蓝桥杯
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="../刷题/蓝桥杯热身赛.html">
            
                <a href="../刷题/蓝桥杯热身赛.html">
            
                    
                    蓝桥杯热身赛
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.8" data-path="../刷题/计算机等级考试(C语言">
            
                <span>
            
                    
                    计算机等级考试(C语言)
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../博客/">
            
                <a href="../博客/">
            
                    
                    博客
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../博客/next主题配置.html">
            
                <a href="../博客/next主题配置.html">
            
                    
                    Next主题配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../博客/一些问题的记录.html">
            
                <a href="../博客/一些问题的记录.html">
            
                    
                    一些问题的记录
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="./">
            
                <a href="./">
            
                    
                    学习Java
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="AQS.html">
            
                <a href="AQS.html">
            
                    
                    AQS
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="HashMap的简单实现.html">
            
                <a href="HashMap的简单实现.html">
            
                    
                    HashMap的简单实现
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="JavaByteCode.html">
            
                <a href="JavaByteCode.html">
            
                    
                    JavaByteCode
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="Java基础.html">
            
                <a href="Java基础.html">
            
                    
                    Java基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.5" data-path="Java多线程.html">
            
                <a href="Java多线程.html">
            
                    
                    Java多线程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.6" data-path="Java多线程并发.html">
            
                <a href="Java多线程并发.html">
            
                    
                    Java多线程并发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.7" data-path="Java爬虫.html">
            
                <a href="Java爬虫.html">
            
                    
                    Java爬虫
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.8" data-path="Java集合.html">
            
                <a href="Java集合.html">
            
                    
                    Java集合
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.8.9" data-path="java常用类.html">
            
                <a href="java常用类.html">
            
                    
                    Java常用类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.10" data-path="jvm.html">
            
                <a href="jvm.html">
            
                    
                    Jvm
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.11" data-path="noifelse.html">
            
                <a href="noifelse.html">
            
                    
                    Noifelse
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.12" data-path="socket.html">
            
                <a href="socket.html">
            
                    
                    Socket
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.13" data-path="一些Java方法.html">
            
                <a href="一些Java方法.html">
            
                    
                    一些Java方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.14" data-path="一些其他人写的博客.html">
            
                <a href="一些其他人写的博客.html">
            
                    
                    一些其他人写的博客
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.15" data-path="硬核空间.html">
            
                <a href="硬核空间.html">
            
                    
                    硬核空间
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.16" data-path="遇到的问题.html">
            
                <a href="遇到的问题.html">
            
                    
                    遇到的问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.17" data-path="阻塞队列.html">
            
                <a href="阻塞队列.html">
            
                    
                    阻塞队列
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../安卓开发/">
            
                <a href="../安卓开发/">
            
                    
                    安卓开发
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../安卓开发/First App.html">
            
                <a href="../安卓开发/First App.html">
            
                    
                    First App
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="../安卓开发/problems.html">
            
                <a href="../安卓开发/problems.html">
            
                    
                    Problems
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../工具/">
            
                <a href="../工具/">
            
                    
                    工具
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../工具/IDEA.html">
            
                <a href="../工具/IDEA.html">
            
                    
                    IDEA
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" data-path="../工具/docker.html">
            
                <a href="../工具/docker.html">
            
                    
                    Docker
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3" data-path="../工具/github.html">
            
                <a href="../工具/github.html">
            
                    
                    Github
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="../数据库/">
            
                <a href="../数据库/">
            
                    
                    数据库
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="../数据库/MVCC.html">
            
                <a href="../数据库/MVCC.html">
            
                    
                    MVCC
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.2" data-path="../数据库/MySQL.html">
            
                <a href="../数据库/MySQL.html">
            
                    
                    MySQL
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.3" data-path="../数据库/Redis.html">
            
                <a href="../数据库/Redis.html">
            
                    
                    Redis
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="../数据结构知识/">
            
                <a href="../数据结构知识/">
            
                    
                    数据结构知识
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.12.1" data-path="../数据结构知识/大话数据结构笔记1.html">
            
                <a href="../数据结构知识/大话数据结构笔记1.html">
            
                    
                    大话数据结构笔记1
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.2" data-path="../数据结构知识/大话数据结构笔记2.html">
            
                <a href="../数据结构知识/大话数据结构笔记2.html">
            
                    
                    大话数据结构笔记2
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="../面试笔试/">
            
                <a href="../面试笔试/">
            
                    
                    面试笔试
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.13.1" data-path="../面试笔试/字节跳动5月11日笔试.html">
            
                <a href="../面试笔试/字节跳动5月11日笔试.html">
            
                    
                    字节跳动5月11日笔试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.2" data-path="../面试笔试/阿里3月23日笔试.html">
            
                <a href="../面试笔试/阿里3月23日笔试.html">
            
                    
                    阿里3月23日笔试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.3" data-path="../面试笔试/面试突击.html">
            
                <a href="../面试笔试/面试突击.html">
            
                    
                    面试突击
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >Java常用类</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h4 id="string&#x548C;stringbuffer&#x7684;&#x533A;&#x522B;">String&#x548C;StringBuffer&#x7684;&#x533A;&#x522B;</h4>
<p>String:</p>
<ol>
<li>&#x662F;&#x5BF9;&#x8C61;&#x4E0D;&#x662F;&#x539F;&#x59CB;&#x7C7B;&#x578B;&#x3002;</li>
<li>&#x4E3A;==&#x4E0D;&#x53EF;&#x53D8;&#x5BF9;&#x8C61;==,&#x4E00;&#x65E6;&#x88AB;&#x521B;&#x5EFA;,&#x5C31;&#x4E0D;&#x80FD;&#x4FEE;&#x6539;&#x5B83;&#x7684;&#x503C;&#x3002;</li>
<li>&#x5BF9;&#x4E8E;&#x5DF2;&#x7ECF;&#x5B58;&#x5728;&#x7684;String&#x5BF9;&#x8C61;&#x7684;&#x4FEE;&#x6539;&#x90FD;&#x662F;&#x91CD;&#x65B0;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x65B0;&#x7684;&#x5BF9;&#x8C61;,&#x7136;&#x540E;&#x628A;&#x65B0;&#x7684;&#x503C;&#x4FDD;&#x5B58;&#x8FDB;&#x53BB;&#x3002;</li>
<li>String&#x662F;final&#x7C7B;,&#x5373;&#x4E0D;&#x80FD;&#x88AB;&#x7EE7;&#x627F;&#x3002;</li>
</ol>
<p>StringBuffer:</p>
<ol>
<li><p>&#x662F;&#x4E00;&#x4E2A;==&#x53EF;&#x53D8;&#x5BF9;&#x8C61;==,&#x5F53;&#x5BF9;&#x5B83;&#x8FDB;&#x884C;&#x4FEE;&#x6539;&#x7684;&#x65F6;&#x5019;&#x4E0D;&#x4F1A;&#x50CF;String&#x90A3;&#x6837;&#x91CD;&#x65B0;&#x5EFA;&#x7ACB;&#x5BF9;&#x8C61;&#x3002;</p>
</li>
<li><p>&#x5B83;&#x53EA;&#x80FD;&#x901A;&#x8FC7;&#x6784;&#x9020;&#x51FD;&#x6570;&#x6765;&#x5EFA;&#x7ACB;&#xFF0C;StringBuffer subffer=new StringBuffer();</p>
</li>
<li><p>&#x5BF9;&#x8C61;&#x88AB;&#x5EFA;&#x7ACB;&#x4EE5;&#x540E;,&#x5728;&#x5185;&#x5B58;&#x4E2D;&#x5C31;&#x4F1A;&#x5206;&#x914D;&#x5185;&#x5B58;&#x7A7A;&#x95F4;,&#x5E76;&#x521D;&#x59CB;&#x4FDD;&#x5B58;&#x4E00;&#x4E2A;null,&#x901A;&#x8FC7;&#x5B83;&#x7684;append&#x65B9;&#x6CD5;&#x5411;&#x5176;&#x8D4B;&#x503C; subffer.append(&#x201C;hello word&#x201D;);</p>
</li>
</ol>
<blockquote>
<p>&#x5B57;&#x7B26;&#x4E32;&#x8FDE;&#x63A5;&#x64CD;&#x4F5C;&#x4E2D;StringBuffer&#x7684;&#x6548;&#x7387;&#x8981;&#x660E;&#x663E;&#x6BD4;String&#x9AD8;;
String&#x5BF9;&#x8C61;&#x662F;&#x4E0D;&#x53EF;&#x53D8;&#x5BF9;&#x8C61;,&#x6BCF;&#x6B21;&#x64CD;&#x4F5C;String&#x90FD;&#x4F1A;&#x5EFA;&#x7ACB;&#x65B0;&#x7684;&#x5BF9;&#x8C61;&#x6765;&#x4FDD;&#x5B58;&#x65B0;&#x7684;&#x503C;&#x3002;
StringBuffer&#x5BF9;&#x8C61;&#x5B9E;&#x4F8B;&#x5316;&#x540E;,&#x53EA;&#x5BF9;&#x8FD9;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x64CD;&#x4F5C;&#x3002;</p>
</blockquote>
<h3 id="&#x5E38;&#x7528;&#x7C7B;&#x548C;&#x65B9;&#x6CD5;">&#x5E38;&#x7528;&#x7C7B;&#x548C;&#x65B9;&#x6CD5;</h3>
<h4 id="&#x4E00;-object&#x7C7B;">&#x4E00; Object&#x7C7B;</h4>
<h5 id="11-tostring">1.1 toString()</h5>
<blockquote>
<p>&#x4E3B;&#x8981;&#x7528;&#x9014;&#xFF1A;&#x91CD;&#x5199;&#x8FD9;&#x4E2A;&#x65B9;&#x6CD5;&#x53EF;&#x4EE5;&#x81EA;&#x5B9A;&#x4E49;&#x5BF9;&#x8C61;&#x8F93;&#x51FA;&#x683C;&#x5F0F;&#xFF08;&#x9ED8;&#x8BA4;&#x683C;&#x5F0F; &#xFF1A;&#x7C7B;&#x540D; + @ +&#x54C8;&#x5E0C;&#x7801;&#x503C;&#xFF09;</p>
</blockquote>
<h5 id="12-equals">1.2 equals()</h5>
<blockquote>
<p>&#x4E3B;&#x8981;&#x7528;&#x9014; : &#x5224;&#x65AD;&#x4E24;&#x4E2A;&#x5BF9;&#x8C61;&#x662F;&#x5426;&#x76F8;&#x540C;&#xFF0C;&#x9ED8;&#x8BA4;&#x7684;&#x662F;&#x6BD4;&#x8F83;&#x4E24;&#x4E2A;&#x5BF9;&#x8C61;&#x7684;&#x5185;&#x5B58;&#x5730;&#x5740;&#xFF0C;&#x4E00;&#x822C;&#x91CD;&#x5199;equals&#x65B9;&#x6CD5;&#x7684;&#x65F6;&#x5019;&#x4E5F;&#x4F1A;&#x91CD;&#x5199;hasCode&#x65B9;&#x6CD5;</p>
</blockquote>
<h5 id="13-hascode">1.3 hasCode()</h5>
<blockquote>
<p>&#x4E3B;&#x8981;&#x7528;&#x9014; : &#x83B7;&#x53D6;&#x7C7B;&#x7684;&#x54C8;&#x5E0C;&#x7801;&#x503C;&#xFF0C;&#x54C8;&#x5E0C;&#x7801;&#x503C;&#x76F8;&#x5F53;&#x4E8E;&#x662F;&#x7C7B;&#x7684;&#x5185;&#x5B58;&#x5730;&#x5740;</p>
</blockquote>
<h4 id="&#x4E8C;-string&#x7C7B;&#x548C;stringbuffer">&#x4E8C; String&#x7C7B;&#x548C;StringBuffer</h4>
<h5 id="21-string&#x7C7B;">2.1 String&#x7C7B;</h5>
<h6 id="211-&#x5B57;&#x8282;&#x6570;&#x7EC4;&#x6784;&#x5EFA;&#x5B57;&#x7B26;&#x4E32;">2.1.1 &#x5B57;&#x8282;&#x6570;&#x7EC4;&#x6784;&#x5EFA;&#x5B57;&#x7B26;&#x4E32;</h6>
<pre><code class="lang-java">String(<span class="hljs-keyword">byte</span>[] bytes)
</code></pre>
<h6 id="212-&#x5B57;&#x7B26;&#x6570;&#x7EC4;&#x6784;&#x5EFA;&#x5B57;&#x7B26;&#x4E32;">2.1.2 &#x5B57;&#x7B26;&#x6570;&#x7EC4;&#x6784;&#x5EFA;&#x5B57;&#x7B26;&#x4E32;</h6>
<pre><code class="lang-java">String(<span class="hljs-keyword">char</span>[] value)
</code></pre>
<h6 id="213-&#x83B7;&#x53D6;&#x7684;&#x65B9;&#x6CD5;">2.1.3 &#x83B7;&#x53D6;&#x7684;&#x65B9;&#x6CD5;</h6>
<pre><code class="lang-java"><span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">length</span><span class="hljs-params">()</span> <span class="hljs-comment">//&#x83B7;&#x53D6;&#x5B57;&#x7B26;&#x4E32;&#x957F;&#x5EA6;</span>
<span class="hljs-keyword">char</span> <span class="hljs-title">charAt</span><span class="hljs-params">(<span class="hljs-keyword">int</span> index)</span> <span class="hljs-comment">//&#x83B7;&#x53D6;&#x7279;&#x5B9A;&#x4F4D;&#x7F6E;&#x7684;&#x5B57;&#x7B26;</span>
<span class="hljs-keyword">int</span> <span class="hljs-title">indexOf</span><span class="hljs-params">(String str)</span> <span class="hljs-comment">//&#x83B7;&#x53D6;&#x5B57;&#x7B26;&#x7684;&#x4F4D;&#x7F6E;</span>
</span></code></pre>
<h6 id="214-&#x5224;&#x65AD;&#x65B9;&#x6CD5;">2.1.4 &#x5224;&#x65AD;&#x65B9;&#x6CD5;</h6>
<pre><code class="lang-java"><span class="hljs-function"><span class="hljs-keyword">boolean</span> <span class="hljs-title">endsWith</span><span class="hljs-params">(String str)</span> <span class="hljs-comment">//&#x662F;&#x5426;&#x4EE5;&#x6307;&#x5B9A;&#x7684;&#x5B57;&#x7B26;&#x7ED3;&#x5C3E;</span>
<span class="hljs-keyword">boolean</span> <span class="hljs-title">isEmpty</span><span class="hljs-params">()</span> <span class="hljs-comment">//&#x662F;&#x5426;&#x4E3A;&#x7A7A;</span>
<span class="hljs-keyword">boolean</span> <span class="hljs-title">contains</span><span class="hljs-params">(Char Sequences)</span> <span class="hljs-comment">//&#x662F;&#x5426;&#x5305;&#x542B;&#x6307;&#x5B9A;&#x7684;&#x5185;&#x5BB9;</span>
<span class="hljs-keyword">boolean</span> <span class="hljs-title">equalsIgnoreCase</span><span class="hljs-params">(String anotherString)</span><span class="hljs-comment">//&#x5FFD;&#x7565;&#x5927;&#x5C0F;&#x5199;&#x662F;&#x5426;&#x76F8;&#x7B49;</span>
</span></code></pre>
<h6 id="215-&#x8F6C;&#x6362;&#x65B9;&#x6CD5;">2.1.5 &#x8F6C;&#x6362;&#x65B9;&#x6CD5;</h6>
<pre><code class="lang-java"><span class="hljs-keyword">char</span>[] toCharArray()  <span class="hljs-comment">//&#x5C06;&#x5B57;&#x7B26;&#x4E32;&#x8F6C;&#x6362;&#x4E3A;&#x5B57;&#x7B26;&#x6570;&#x7EC4;</span>
<span class="hljs-keyword">byte</span>[] getBytes()  <span class="hljs-comment">//&#x5C06;&#x5B57;&#x7B26;&#x4E32;&#x8F6C;&#x6362;&#x4E3A;&#x5B57;&#x8282;&#x6570;&#x7EC4;</span>
</code></pre>
<h6 id="216-&#x5176;&#x4ED6;&#x65B9;&#x6CD5;">2.1.6 &#x5176;&#x4ED6;&#x65B9;&#x6CD5;</h6>
<pre><code class="lang-java">String[] split(String regex) <span class="hljs-comment">//&#x5206;&#x5272;&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x65B9;&#x6CD5;</span>
<span class="hljs-function">String <span class="hljs-title">substring</span><span class="hljs-params">(<span class="hljs-keyword">int</span> beginIndex)</span> <span class="hljs-comment">//&#x622A;&#x53D6;&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x65B9;&#x6CD5;</span>
String <span class="hljs-title">toUpperCase</span><span class="hljs-params">()</span> <span class="hljs-comment">//&#x8F6C;&#x5927;&#x5199;</span>
String <span class="hljs-title">trim</span><span class="hljs-params">()</span> <span class="hljs-comment">//&#x53BB;&#x9664;&#x5B57;&#x7B26;&#x4E32;&#x9996;&#x5C3E;&#x7A7A;&#x683C;</span>
</span></code></pre>
<h5 id="22-stringbuffer-&#x4E0E;-stringbuilder">2.2 StringBuffer &#x4E0E; StringBuilder</h5>
<blockquote>
<p>StringBuffer&#x548C;StringBuilder&#x4E3B;&#x8981;&#x7528;&#x4E8E;&#x5BF9;&#x5B57;&#x7B26;&#x4E32;&#x9891;&#x7E41;&#x589E;&#x5220;&#x6539;&#x67E5;&#x7684;&#x60C5;&#x51B5;</p>
</blockquote>
<h6 id="221-&#x6DFB;&#x52A0;&#x7684;&#x65B9;&#x6CD5;">2.2.1 &#x6DFB;&#x52A0;&#x7684;&#x65B9;&#x6CD5;</h6>
<pre><code class="lang-java">append() <span class="hljs-comment">//&#x6DFB;&#x52A0;&#x5B57;&#x7B26;</span>
insert(<span class="hljs-keyword">int</span> offset,b) <span class="hljs-comment">//&#x63D2;&#x5165;&#x7D22;&#x5F15;&#x503C;&#xFF0C;&#x63D2;&#x5165;&#x7684;&#x5185;&#x5BB9;</span>
</code></pre>
<h6 id="222-&#x5220;&#x9664;&#x7684;&#x65B9;&#x6CD5;">2.2.2 &#x5220;&#x9664;&#x7684;&#x65B9;&#x6CD5;</h6>
<pre><code class="lang-java">delete(<span class="hljs-keyword">int</span> start, <span class="hljs-keyword">int</span> end) <span class="hljs-comment">//&#x6839;&#x636E;&#x6307;&#x5B9A;&#x7684;&#x5F00;&#x59CB;&#x4E0E;&#x7ED3;&#x675F;&#x7684;&#x7D22;&#x5F15;&#x503C;&#x5220;&#x9664;&#x5BF9;&#x5E94;&#x7684;&#x5185;&#x5BB9;</span>
deleteCharAt(<span class="hljs-keyword">int</span> index) <span class="hljs-comment">//&#x6839;&#x636E;&#x6307;&#x5B9A;&#x7684;&#x7D22;&#x5F15;&#x5220;&#x9664;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;</span>
</code></pre>
<h6 id="223-&#x4FEE;&#x6539;">2.2.3 &#x4FEE;&#x6539;</h6>
<pre><code class="lang-java">replace(<span class="hljs-keyword">int</span> start, <span class="hljs-keyword">int</span> end , String str) <span class="hljs-comment">//&#x628A;&#x6307;&#x5B9A;&#x7D22;&#x5F15;&#x503C;&#x7684;&#x5B57;&#x7B26;&#x66FF;&#x6362;&#x4E3A;&#x6307;&#x5B9A;&#x7684;&#x5B57;&#x7B26;</span>
reverse() <span class="hljs-comment">// &#x53CD;&#x8F6C;&#x5B57;&#x7B26;&#x4E32;</span>
</code></pre>
<h6 id="224-&#x67E5;&#x770B;">2.2.4 &#x67E5;&#x770B;</h6>
<pre><code class="lang-java"> indexOf(String str, <span class="hljs-keyword">int</span> fromIdnex) <span class="hljs-comment">// &#x67E5;&#x627E;&#x6307;&#x5B9A;&#x7684;&#x5B57;&#x7B26;&#x4E32;&#x7B2C;&#x4E00;&#x6B21;&#x51FA;&#x73B0;&#x7684;&#x7D22;&#x5F15;&#x503C;&#xFF0C;&#x5E76;&#x4E14;&#x6307;&#x5B9A;&#x5F00;&#x59CB;&#x67E5;&#x627E;&#x7684;&#x4F4D;&#x7F6E;</span>
</code></pre>
<h6 id="225-stringbuffer-&#x4E0E;-stringbuilder&#x5E38;&#x7528;-&#x7684;&#x76F8;&#x540C;&#x4E0E;&#x4E0D;&#x540C;">2.2.5 StringBuffer &#x4E0E; StringBuilder(&#x5E38;&#x7528;) &#x7684;&#x76F8;&#x540C;&#x4E0E;&#x4E0D;&#x540C;</h6>
<p>&#x76F8;&#x540C;&#xFF1A;</p>
<blockquote>
<p>1.&#x4E24;&#x4E2A;&#x7C7B;&#x90FD;&#x662F;&#x5B57;&#x7B26;&#x4E32;&#x7F13;&#x51B2;&#x7C7B;
2.&#x4E24;&#x4E2A;&#x7C7B;&#x7684;&#x65B9;&#x6CD5;&#x90FD;&#x4E00;&#x6837;</p>
</blockquote>
<p>&#x4E0D;&#x540C;:</p>
<blockquote>
<p>1.StringBuffer&#x662F;&#x7EBF;&#x7A0B;&#x5B89;&#x5168;&#x7684;&#xFF0C;&#x64CD;&#x4F5C;&#x6548;&#x7387;&#x4F4E;&#xFF0C;StringBuilder&#x662F;&#x7EBF;&#x7A0B;&#x975E;&#x5B89;&#x5168;&#x7684;,&#x64CD;&#x4F5C;&#x6548;&#x7387;&#x9AD8;
2.StringBuffer&#x662F;jdk1.0&#x51FA;&#x73B0;&#x7684;, StringBuilder &#x662F;jdk1.5&#x7684;&#x65F6;&#x5019;&#x51FA;&#x73B0;&#x7684;.</p>
</blockquote>
<h4 id="&#x4E09;-system-&#x548C;-runtime&#x7C7B;">&#x4E09; System &#x548C; RunTime&#x7C7B;</h4>
<h5 id="31-system&#x7C7B;">3.1 System&#x7C7B;</h5>
<h6 id="311-system&#x5E38;&#x7528;&#x65B9;&#x6CD5;">3.1.1 System&#x5E38;&#x7528;&#x65B9;&#x6CD5;</h6>
<pre><code class="lang-java">currentTimeMillis() <span class="hljs-comment">//&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x7CFB;&#x7EDF;&#x65F6;&#x95F4;</span>
exit(<span class="hljs-keyword">int</span> status) <span class="hljs-comment">//&#x9000;&#x51FA;jvm </span>
gc() <span class="hljs-comment">//&#x5EFA;&#x8BAE;jvm&#x542F;&#x52A8;&#x5783;&#x573E;&#x56DE;&#x6536;&#x673A;&#x5236;</span>
getProperties();<span class="hljs-comment">//&#x83B7;&#x53D6;&#x7CFB;&#x7EDF;&#x7684;&#x6240;&#x6709;&#x5C5E;&#x6027;</span>
</code></pre>
<h5 id="32-runtime&#x7C7B;">3.2 RunTime&#x7C7B;</h5>
<h6 id="321-runtime&#x5E38;&#x7528;&#x65B9;&#x6CD5;">3.2.1 RunTime&#x5E38;&#x7528;&#x65B9;&#x6CD5;</h6>
<pre><code class="lang-java">getRuntime(); <span class="hljs-comment">// &#x8FD4;&#x56DE;&#x5F53;&#x524D;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x7684;&#x8FD0;&#x884C;&#x73AF;&#x5883;&#x5BF9;&#x8C61;</span>
exec(String command) <span class="hljs-comment">//&#x6839;&#x636E;&#x6307;&#x5B9A;&#x7684;&#x8DEF;&#x5F84;&#x6267;&#x884C;&#x5BF9;&#x5E94;&#x7684;&#x53EF;&#x6267;&#x884C;&#x6587;&#x4EF6;</span>
freeMemory() <span class="hljs-comment">//&#x83B7;&#x53D6;jvm&#x7684;&#x7A7A;&#x95F2;&#x5185;&#x5B58;,&#x4EE5;&#x5B57;&#x8282;&#x4E3A;&#x5355;&#x4F4D;</span>
totalMemory() <span class="hljs-comment">//&#x8FD4;&#x56DE;jvm&#x7684;&#x5185;&#x5B58;&#x603B;&#x91CF;</span>
</code></pre>
<h4 id="&#x56DB;-&#x65E5;&#x671F;&#x7C7B;">&#x56DB; &#x65E5;&#x671F;&#x7C7B;</h4>
<h5 id="41-calendar&#x7C7B;">4.1 Calendar&#x7C7B;</h5>
<pre><code class="lang-java">Calendar calendar = getInstance(); <span class="hljs-comment">//&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x7684;&#x7CFB;&#x7EDF;&#x65F6;&#x95F4;&#x7C7B;</span>
calendar.get(Calendar.YEAR)<span class="hljs-comment">//&#x83B7;&#x53D6;&#x5E74;&#x4EFD;</span>
calendar.get(Calendar.MONTH)+<span class="hljs-number">1</span> <span class="hljs-comment">//&#x83B7;&#x53D6;&#x6708;&#x4EFD;</span>
calendar.get(Calendar.HOUR_OF_DAY&#xFF09; <span class="hljs-comment">//&#x83B7;&#x53D6;&#x5C0F;&#x65F6;,24&#x5C0F;&#x65F6;&#x5236;</span>
</code></pre>
<h5 id="42-simpledateformat&#x7C7B;&#x5E38;&#x7528;">4.2 SimpleDateFormat&#x7C7B;(&#x5E38;&#x7528;)</h5>
<h6 id="421-&#x628A;&#x65E5;&#x671F;&#x8F6C;&#x6362;&#x6210;&#x6307;&#x5B9A;&#x683C;&#x5F0F;&#x7684;&#x5B57;&#x7B26;&#x4E32;">4.2.1 &#x628A;&#x65E5;&#x671F;&#x8F6C;&#x6362;&#x6210;&#x6307;&#x5B9A;&#x683C;&#x5F0F;&#x7684;&#x5B57;&#x7B26;&#x4E32;</h6>
<pre><code class="lang-java">Date date = <span class="hljs-keyword">new</span> Date();<span class="hljs-comment">//&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x7684;&#x7CFB;&#x7EDF;&#x65F6;&#x95F4;</span>
SimpleDateFormat simpleFormat = <span class="hljs-keyword">new</span> SimpleDateFormat(<span class="hljs-string">&quot;yyyy&#x5E74;MM&#x6708;dd&#x65E5; HH:mm:ss&quot;</span>);<span class="hljs-comment">//&#x8BBE;&#x7F6E;&#x683C;&#x5F0F;&#x5316;&#x6A21;&#x5F0F;</span>
String time = simpleFormat.format(date);
</code></pre>
<h6 id="422-&#x628A;&#x5B57;&#x7B26;&#x4E32;&#x8F6C;&#x6362;&#x4E3A;&#x5BF9;&#x5E94;&#x7684;&#x65E5;&#x671F;">4.2.2 &#x628A;&#x5B57;&#x7B26;&#x4E32;&#x8F6C;&#x6362;&#x4E3A;&#x5BF9;&#x5E94;&#x7684;&#x65E5;&#x671F;</h6>
<pre><code class="lang-java">SimpleDateFormat simpleFormat = <span class="hljs-keyword">new</span> SimpleDateFormat(<span class="hljs-string">&quot;yyyy&#x5E74;MM&#x6708;dd&#x65E5; HH:mm:ss&quot;</span>);
String birthday = <span class="hljs-string">&quot;2000&#x5E74;12&#x6708;26&#x65E5; 11:29:08&quot;</span>;
Date date = simpleFormat.parse(birthday);<span class="hljs-comment">//&#x6CE8;&#x610F;:&#x6307;&#x5B9A;&#x7684;&#x5B57;&#x7B26;&#x4E32;&#x683C;&#x5F0F;&#x5FC5;&#x987B;&#x8981;&#x4E0E;SimpleDateFormat&#x6A21;&#x5F0F;&#x4E00;&#x81F3;</span>
</code></pre>
<h4 id="&#x4E94;-math&#x7C7B;">&#x4E94; Math&#x7C7B;</h4>
<h5 id="51&#x5E38;&#x7528;&#x7684;&#x65B9;&#x6CD5;">5.1&#x5E38;&#x7528;&#x7684;&#x65B9;&#x6CD5;</h5>
<pre><code class="lang-java">abs(<span class="hljs-keyword">double</span> a) <span class="hljs-comment">//&#x83B7;&#x53D6;&#x7EDD;&#x5BF9;&#x503C; Math.abs(-3)</span>
ceil(<span class="hljs-keyword">double</span> a) <span class="hljs-comment">//&#x5411;&#x4E0A;&#x53D6;&#x6574;</span>
floor(<span class="hljs-keyword">double</span> a) <span class="hljs-comment">//&#x5411;&#x4E0B;&#x53D6;&#x6574;</span>
round(<span class="hljs-keyword">float</span> a) <span class="hljs-comment">//&#x56DB;&#x820D;&#x4E94;&#x5165;</span>
</code></pre>
<h5 id="52-&#x968F;&#x673A;&#x6570;&#x7C7B;random">5.2 &#x968F;&#x673A;&#x6570;&#x7C7B;(Random)</h5>
<pre><code class="lang-java">Random random = <span class="hljs-keyword">new</span> Random();
<span class="hljs-keyword">int</span> num = random.nextInt(<span class="hljs-number">10</span>); <span class="hljs-comment">//&#x4EA7;&#x751F;0-10&#x4E4B;&#x95F4;&#x7684;&#x968F;&#x673A;&#x6570;</span>
</code></pre>
<h4 id="&#x516D;-scanner&#x7C7B;">&#x516D; Scanner&#x7C7B;</h4>
<p>&#x91CD;&#x70B9;&#x8BB2;&#x4E00;&#x4E0B;next()&#x548C;nextLine()&#x7684;&#x533A;&#x522B;</p>
<h5 id="next">next()</h5>
<p>&#x53EA;&#x8BFB;&#x53D6;&#x8F93;&#x5165;&#x76F4;&#x5230;&#x7A7A;&#x683C;&#x3002;&#x5B83;&#x4E0D;&#x80FD;&#x8BFB;&#x4E24;&#x4E2A;&#x7531;&#x7A7A;&#x683C;&#x6216;&#x7B26;&#x53F7;&#x9694;&#x5F00;&#x7684;&#x5355;&#x8BCD;&#x3002;&#x6B64;&#x5916;&#xFF0C;next()&#x5728;&#x8BFB;&#x53D6;&#x8F93;&#x5165;&#x540E;&#x5C06;&#x5149;&#x6807;&#x653E;&#x5728;&#x540C;&#x4E00;&#x884C;&#x4E2D;&#x3002;(next()&#x53EA;&#x8BFB;&#x7A7A;&#x683C;&#x4E4B;&#x524D;&#x7684;&#x6570;&#x636E;,&#x5E76;&#x4E14;&#x5149;&#x6807;&#x6307;&#x5411;&#x672C;&#x884C;)</p>
<h5 id="nextline">nextLine()</h5>
<p>&#x8BFB;&#x53D6;&#x8F93;&#x5165;&#xFF0C;&#x5305;&#x62EC;&#x5355;&#x8BCD;&#x4E4B;&#x95F4;&#x7684;&#x7A7A;&#x683C;&#x548C;&#x9664;&#x56DE;&#x8F66;&#x4EE5;&#x5916;&#x7684;&#x6240;&#x6709;&#x7B26;&#x53F7;(&#x5373;&#x3002;&#x5B83;&#x8BFB;&#x5230;&#x884C;&#x5C3E;)&#x3002;&#x8BFB;&#x53D6;&#x8F93;&#x5165;&#x540E;&#xFF0C;nextLine()&#x5C06;&#x5149;&#x6807;&#x5B9A;&#x4F4D;&#x5728;&#x4E0B;&#x4E00;&#x884C;&#x3002;</p>
<p>&#x6F14;&#x793A;1</p>
<pre><code class="lang-Java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Text</span> </span>{
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">main</span><span class="hljs-params">(String []args)</span> </span>{
        Scanner input = <span class="hljs-keyword">new</span> Scanner(System.in);
        System.out.println(<span class="hljs-string">&quot;&#x8BF7;&#x8F93;&#x5165;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;(&#x4E2D;&#x95F4;&#x80FD;&#x52A0;&#x7A7A;&#x683C;&#x6216;&#x7B26;&#x53F7;)&quot;</span>);
        String a = input.nextLine();
        System.out.println(<span class="hljs-string">&quot;&#x8BF7;&#x8F93;&#x5165;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;(&#x4E2D;&#x95F4;&#x4E0D;&#x80FD;&#x52A0;&#x7A7A;&#x683C;&#x6216;&#x7B26;&#x53F7;)&quot;</span>);
        String b = input.next();
        System.out.println(<span class="hljs-string">&quot;&#x8BF7;&#x8F93;&#x5165;&#x4E00;&#x4E2A;&#x6574;&#x6570;&quot;</span>);
        <span class="hljs-keyword">int</span> c;
        c = input.nextInt();
        System.out.println(<span class="hljs-string">&quot;&#x8BF7;&#x8F93;&#x5165;&#x4E00;&#x4E2A;double&#x7C7B;&#x578B;&#x7684;&#x5C0F;&#x6570;&quot;</span>);
        <span class="hljs-keyword">double</span> d = input.nextDouble();
        System.out.println(<span class="hljs-string">&quot;&#x8BF7;&#x8F93;&#x5165;&#x4E00;&#x4E2A;float&#x7C7B;&#x578B;&#x7684;&#x5C0F;&#x6570;&quot;</span>);
        <span class="hljs-keyword">float</span> f = input.nextFloat();
        System.out.println(<span class="hljs-string">&quot;&#x6309;&#x987A;&#x5E8F;&#x8F93;&#x51FA;abcdf&#x7684;&#x503C;&#xFF1A;&quot;</span>);
        System.out.println(a);
        System.out.println(b);
        System.out.println(c);
        System.out.println(d);
        System.out.println(f);
    }
}
</code></pre>
<p>&#x7ED3;&#x679C;</p>
<pre><code>&#x8BF7;&#x8F93;&#x5165;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;(&#x4E2D;&#x95F4;&#x80FD;&#x52A0;&#x7A7A;&#x683C;&#x6216;&#x7B26;&#x53F7;)
&#x6211;&#x7231;&#x7956;&#x56FD;&#xFF01;
&#x8BF7;&#x8F93;&#x5165;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;(&#x4E2D;&#x95F4;&#x4E0D;&#x80FD;&#x52A0;&#x7A7A;&#x683C;&#x6216;&#x7B26;&#x53F7;)
ILoveChina
&#x8BF7;&#x8F93;&#x5165;&#x4E00;&#x4E2A;&#x6574;&#x6570;
520
&#x8BF7;&#x8F93;&#x5165;&#x4E00;&#x4E2A;double&#x7C7B;&#x578B;&#x7684;&#x5C0F;&#x6570;
12.26e3
&#x8BF7;&#x8F93;&#x5165;&#x4E00;&#x4E2A;float&#x7C7B;&#x578B;&#x7684;&#x5C0F;&#x6570;
3.1415926
&#x6309;&#x987A;&#x5E8F;&#x8F93;&#x51FA;abcdf&#x7684;&#x503C;&#xFF1A;
&#x6211;&#x7231;&#x7956;&#x56FD;&#xFF01;
ILoveChina
520
12260.0
3.1415925
</code></pre><p>&#x6F14;&#x793A;2</p>
<pre><code class="lang-Java">  <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">main</span><span class="hljs-params">(String[] args)</span> </span>{
            Scanner scan = <span class="hljs-keyword">new</span> Scanner(System.in);    <span class="hljs-comment">//&#x6784;&#x9020;Scanner&#x7C7B;&#x7684;&#x5BF9;&#x8C61;scan&#xFF0C;&#x63A5;&#x6536;&#x4ECE;&#x63A7;&#x5236;&#x53F0;&#x8F93;&#x5165;&#x7684;&#x4FE1;&#x606F;</span>
            System.out.println(<span class="hljs-string">&quot;&#x8BF7;&#x8F93;&#x5165;&#x4F60;&#x7684;&#x59D3;&#x540D;&quot;</span>);
            String name = scan.nextLine();<span class="hljs-comment">//&#x63A5;&#x6536;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;&#xFF0C;&#x53EF;&#x4EE5;&#x52A0;&#x9664;Enter&#x4EE5;&#x5916;&#x7684;&#x6240;&#x6709;&#x7B26;&#x53F7;&#xFF0C;&#x5305;&#x62EC;&#x7A7A;&#x683C;&#x548C;Tab</span>
            System.out.println(<span class="hljs-string">&quot;&#x8BF7;&#x8F93;&#x5165;&#x4F60;&#x7684;ID&quot;</span>);
            String ID ;
            <span class="hljs-keyword">while</span>(scan.hasNextLine()) {<span class="hljs-comment">// hasNextLine()&#x65B9;&#x6CD5;&#x5224;&#x65AD;&#x5F53;&#x524D;&#x662F;&#x5426;&#x6709;&#x8F93;&#x5165;&#xFF0C;&#x5F53;&#x952E;&#x76D8;&#x6709;&#x8F93;&#x5165;&#x540E;&#x6267;&#x884C;&#x5FAA;&#x73AF;</span>
                <span class="hljs-keyword">if</span>(scan.hasNextInt()) {<span class="hljs-comment">// &#x5224;&#x65AD;&#x8F93;&#x5165;&#x7684;&#x503C;&#x662F;&#x5426;&#x4E3A;&#x6574;&#x6570;&#x7C7B;&#x578B;&#xFF0C;&#x5F53;&#x4E3A;&#x6574;&#x6570;&#x7C7B;&#x578B;&#x65F6;&#x6267;&#x884C;&#x5FAA;&#x73AF;</span>
                    ID = String.valueOf(scan.nextInt());
                    System.out.println(<span class="hljs-string">&quot;&#x4F60;&#x8F93;&#x5165;&#x7684;&#x59D3;&#x540D;&#x4E3A;&#xFF1A;&quot;</span>+name);
                    System.out.println(<span class="hljs-string">&quot;&#x4F60;&#x8F93;&#x5165;&#x7684;ID&#x4E3A;&#xFF1A;&quot;</span>+ID);
                    <span class="hljs-keyword">break</span>;
                }<span class="hljs-keyword">else</span> {
                    System.out.println(<span class="hljs-string">&quot;&#x8BF7;&#x8F93;&#x5165;&#x6570;&#x5B57;&#x54E6;&#xFF01;&quot;</span>);
                    ID = String.valueOf(scan.nextInt());
                }
            }
        }
</code></pre>
<p>&#x7ED3;&#x679C;</p>
<pre><code>&#x8BF7;&#x8F93;&#x5165;&#x4F60;&#x7684;&#x59D3;&#x540D;
&#x897F;&#x5730;&#x90A3;&#x975E;
&#x8BF7;&#x8F93;&#x5165;&#x4F60;&#x7684;ID
q764323221
&#x8BF7;&#x8F93;&#x5165;&#x6570;&#x5B57;&#x54E6;&#xFF01;
764323221
</code></pre>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="Java集合.html" class="navigation navigation-prev " aria-label="Previous page: Java集合">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="jvm.html" class="navigation navigation-next " aria-label="Next page: Jvm">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Java常用类","level":"1.8.9","depth":2,"next":{"title":"Jvm","level":"1.8.10","depth":2,"path":"学习java/jvm.md","ref":"学习java/jvm.md","articles":[]},"previous":{"title":"Java集合","level":"1.8.8","depth":2,"path":"学习java/Java集合.md","ref":"学习java/Java集合.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-search","-lunr","-sharing","-anchor-navigation-ex","todo","code","-katex","github","-summary","search-pro","chapter-fold","theme-comscore","toggle-chapters","flexible-alerts"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"chapter-fold":{},"github":{"url":"https://github.com/BluePrintYang"},"todo":{},"search-pro":{},"code":{"copyButtons":true},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"anchor-navigation-ex":{"showLevel":false,"showGoTop":true,"isRewritePageTitle":true,"isShowTocTitleIcon":true,"tocLevel1Icon":"fa fa-hand-o-right","tocLevel2Icon":"fa fa-hand-o-right","tocLevel3Icon":"fa fa-hand-o-right"},"theme-comscore":{},"flexible-alerts":{"danger":{"className":"danger","icon":"fa fa-ban","label":"Attention"},"note":{"className":"info","icon":"fa fa-info-circle","label":"Note"},"style":"callout","tip":{"className":"tip","icon":"fa fa-lightbulb-o","label":"Tip"},"warning":{"className":"warning","icon":"fa fa-exclamation-triangle","label":"Warning"}},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"toggle-chapters":{}},"theme":"default","author":"yanglonglong","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"My Study Note","language":"zh-hans","links":{"sidebar":{"My Blog":"https://www.yangllong.top/"}},"gitbook":"*"},"file":{"path":"学习java/java常用类.md","mtime":"2020-06-29T16:04:36.000Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-01-14T07:15:50.272Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-github/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-toggle-chapters/toggle.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-flexible-alerts/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

